package com.zmn.oms.business.interfaces.work;


import com.zmn.oms.common.dro.normal.order.OrderRelationDRO;
import com.zmn.oms.model.entity.work.OrderBaseEsQuery;
import com.zmn.oms.model.entity.work.OrderWorkQuery;
import com.zmn.base.oms.common.model.es.orderwork.EsOrderWork;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;

import java.util.List;

/**
 * 类描述：啄木鸟-普通单-列表查询
 * @author  lujia
 * @date   2018-11-29 14:13:04
 */
public interface OrderWorkListBService {

    /**
     * 构建查询对象
     *
     * @param query
     * @return
     */
    NativeSearchQuery getSearchQueryByQuery(OrderBaseEsQuery query);

    /**
     * 查询工单关联的工单
     * @param workId
     * @return
     */
    OrderRelationDRO getOrderRelationByOrderIdAndWorkId(Long orderId, Long workId);

    /**
     * 工单分页查询
     * @param query
     * @param searchQuery
     * @return
     */
    List<EsOrderWork> listPageOrderWorkBySearchQuery(OrderBaseEsQuery query, NativeSearchQuery searchQuery);

    /**
     * 工单分页查询
     * @param query 工单查询条件
     * @return 订单列表
     */
    List<EsOrderWork> listPageOrderWorkByQuery(OrderBaseEsQuery query);

    /**
     * 查询临时用户订单
     * @param query
     * @return
     */
    List<EsOrderWork> listTempUserOrderWorkByQuery(OrderWorkQuery query);

    /**
     * 通过Id查询工单
     * @param id
     * @return
     */
    EsOrderWork findOrderWorkById(Long id);

    /**
     * 根据条件查询订单数量
     * @param query
     * @return
     */
    Integer countOrderWorkByQuery(OrderBaseEsQuery query);

    /**
     * 根据条件查询订单数量
     * @param searchQuery
     * @return
     */
    Integer countOrderWorkByQuery(NativeSearchQuery searchQuery);

    /**
     * 根据条件查询订单包含工程师数量
     * @param query
     * @return
     */
    Integer countMasterByQuery(OrderBaseEsQuery query);

    /**
     * 获取优惠券优惠总额
     * @param orderIdList 单次最多查询5000条
     * @return
     */
    Integer getCouponDiscountAmountByOrderIdList(List<Long> orderIdList);

    /**
     * 查询订单成功返修数量
     *
     * @param orderId
     * @param workId
     * @return
     */
    Integer countReworkSuccessByWorkId(Long orderId, Long workId);
}
